package com.zyf.cloud.services.userservice.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 配置内部类
 */
@Slf4j
@Controller
@Configuration
class  Config {

    @Value("${user.home}")
    private String userName;

    /**
     * 端口
     */
    @Value("${server.port}")
    private String port;/**
     * 启动成功
     */
    @Bean
    public ApplicationRunner applicationRunner() {
        return applicationArguments -> {
            try {
                InetAddress ia = InetAddress.getLocalHost();
                //获取本机内网IP
                log.info("启动成功：" + "http://" + ia.getHostAddress() + ":" + port + "/");
                log.info("${user.home} ：" + userName);
            } catch (UnknownHostException ex) {
                ex.printStackTrace();
            }
        };
    }
}
